import request from '@/utils/request'
import JSONBigInt from 'json-bigint'
import {serviceModulePrefix, useDecorateApi} from "@/utils/tools";

const JSONBigIntStr = JSONBigInt({storeAsString: true})



// 获取管理端班课列表
export function classArrData(options) {
  return request({
    url: '/bk/info/list',
    method: 'get',
    params: options
    // transformResponse: res => JSONBigIntStr.parse(res)
  })
}


// 获取老师端班课列表
export function TclassArrData(options) {
  return request({
    url: '/bk/info/t/list',
    method: 'get',
    params: options
    // transformResponse: res => JSONBigIntStr.parse(res)
  })
}


// 获取学生端班课列表
export function SclassArrData(options) {
  return request({
    url: '/bk/info/s/list',
    method: 'get',
    params: options
    // transformResponse: res => JSONBigIntStr.parse(res)
  })
}

// 获取优秀班课列表
export function excellent_bk() {
  return request({
    url: '/t/home/right',
    method: 'get'

    // transformResponse: res => JSONBigIntStr.parse(res)
  })
}

// 获取一条班课列表
export function classrow(id) {
  return request({
    url: `/bk/info/${id}`,
    method: 'get'
  })
}


//新建班课
export function addclass(options) {
  return request({
    url: '/bk/info',
    method: 'post',
    data: options
  })
}

//删除班课
export function removeClass(id) {
  return request({
    url: `/bk/info/${id}`,
    method: 'delete'
  })
}


//更新班课
export function upclass(options) {
  return request({
    url: '/bk/info',
    method: 'put',
    data: options
  })
}

//复制班课
export function cloneClass(id) {
  return request({
    url: '/bksystem/info/clone/' + id,
    method: 'get'
  })
}


//上传封面
export function uploadCover(options) {
  return request({
    url: "/oss/oss/upload",
    method: 'post',
    data: options
  })
}


//获取班课大纲
export function syllabusList(options) {
  return request({
    url: "/bksystem/outline/list",
    method: 'get',
    params: options
  })
}

//保存班课大纲
export function saveSyllabus(options) {
  return request({
    url: "/bksystem/outline",
    method: 'post',
    data: options
  })
}


//获取班课资料
export function materialList(options) {
  return request({
    url: "/bksystem/material/list",
    method: 'get',
    params: options
  })
}


//上传oss成功会换取数据库id
export function getFileID(options) {
  return request({
    url: "/oss/oss/saveOss",
    method: 'post',
    data: options
  })
}

//新增资料
export function addMaterialFill(options) {
  return request({
    url: "/bksystem/material",
    method: 'post',
    data: options
  })
}


//删除资料
export function deleteData(str) {
  return request({
    url: "/bksystem/material/" + str,
    method: 'delete'
  })
}


//修改资料名称
export function reNameData(filename, ossid) {
  return request({
    url: `/oss/oss/updateCustomName/${filename}/${ossid}`,
    method: 'post'
  })
}


//根据班课id获取大纲列表
export function chapterInit(id) {
  return request({
    url: '/bksystem/outline/teachDesign/' + id,
    method: 'get'
  })
}

// 触发学生已学习章节
export const apiStudyTrigger = (id, opts) => useDecorateApi(request({
  url: `${serviceModulePrefix}/stInfo/asr/${id}`,
  method: 'post'
}), {
  ...opts
})


//查询单个教学设计
export function teachDesignDetail(id) {
  return request({
    url: '/bksystem/outline/teachDesignDetail/' + id,
    method: 'get',
    transformResponse: [function (data) {
      return JSONBigIntStr.parse(data)
    }]
  })
}





